package com.tuozixuan;

import java.io.File;

import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import static com.tuozixuan.GitDemoConstants.*;

public class GitCloneDemo {

	public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException {
		
		// 提供用户名和密码的验证
		UsernamePasswordCredentialsProvider provider = new UsernamePasswordCredentialsProvider(USERNAME, PASSWORD);

		// clone 仓库到指定目录
		Git git = Git.cloneRepository().setURI(GIT_URL).setDirectory(new File(LOCAL_DIR))
		        .setCredentialsProvider(provider).call();
		git.close();
	}

}
